<?php
require_once(ROOTPATH .'class'. DS .'mail'. DS .'class.phpmailer.php');
require_once(ROOTPATH .'class'. DS .'mail'. DS .'class.smtp.php');

class email{
	 function send($to,$name,$title,$body){
		$mail = new PHPMailer();
		if( 'linux' == strtolower(PHP_OS) )
			$mail-> IsMail() ;//IsSMTP(); // 使用(其他就用SMTP)
		else //if( 'WINNT' == PHP_OS )
			$mail-> IsSMTP(); // 使用(其他就用SMTP)
		$mail->SMTPSecure = "ssl"; // 设置连接服务器前缀
		$mail->Host = "smtp.gmail.com";      // GMAIL的SMTP
		$mail->Port = 465;                   // GMAIL的SMTP端口号 465
		$mail->SMTPAuth = true; // 开启SMTP认证
		$mail->Username =  EMAIL_USER ; // GMAIL用户名,必须以@gmail结尾
		$mail->Password = EMAIL_PASS ; // GMAIL密码
		//$webmaster_email = "xxx@gmail.com"; //回复到该地址
		$mail->From = EMAIL_USER ;
		$mail->FromName = "Design Engine";
		$mail->WordWrap = 100;  // 设定 word wrap
		//$mail->AddAttachment("/var/tmp/file.tar.gz"); // 附件1
		//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // 附件2
		$mail->IsHTML(true); // 以HTML发送
		$mail -> CharSet = 'UTF-8';
		
		
		$mail->AddAddress( $to ,$name);
		
		$mail->AddAddress( EMAIL_USER ,'收Design的邮件['. date('Y-m-d H:i',time()) .']');
		
		$mail->Subject = $title ;
		$mail->Body = $body;
		if(!$mail->Send()){
			$resuelt = 'false' ; //echo "Mailer Error: " . $mail->ErrorInfo;
		}else{
			$resuelt = 'true'; //echo 'OK';
		}
		return $resuelt ;
		
	}
	 

}
?>